import React from 'react';
import { Switch, Route } from "react-router-dom";
import loadable from './utils/loadable'

import Authenticate from "./components/reqAuth";


import ErrorPage from './pages/error/index'

const Login = loadable(() => import("./pages/login/index"));
const Home = loadable(() => import("./pages/home/index"));
const NewsDetail = loadable(() => import("./pages/home/newsDetail"));
const StydyPage = loadable(() => import("./pages/study/index"));
const LCDetail = loadable(() => import("./pages/study/lcDetail"));
const OnlineCode = loadable(() => import("./pages/onlineCode/index"));
const AdminPage = loadable(() => import("./pages/admin/index"));

function App() {
  return (
    <Switch>
      <Route path="/" exact component={Home} />
      <Route path="/login" exact component={Login} />
      <Route path="/h" component={Home} />
      <Route path="/n-d" component={NewsDetail} />
      <Route path="/s" component={StydyPage} />
      <Route path="/lc-d" component={LCDetail} />
      <Route path="/c" component={OnlineCode} />
      <Route path="/admin" component={Authenticate(AdminPage)} />
      <Route component={ErrorPage}></Route>
    </Switch>
  );
}

export default App;
